package cn.edu.henu.team.table;

import org.greenrobot.greendao.query.QueryBuilder;

import java.util.List;

import cn.edu.henu.team.application.MyApplication;
import cn.edu.henu.team.database.DaoSession;
import cn.edu.henu.team.database.diagLogDao;

public class diagLogUtils {
    private static diagLogDao mDiagLogDao;
    private static DaoSession daoSession;

    static {
        mDiagLogDao = MyApplication.getInstances().getDaoSession().getDiagLogDao();
        daoSession = MyApplication.getInstances().getDaoSession();
    }

    //增加
    public static void insert(diagLog q) {
        mDiagLogDao.insertOrReplace(q);
    }

    //删除全部
    public static void deleteAll(){
        mDiagLogDao.deleteAll();
    }
    //查询全部
    public static List<diagLog> loadAll() {
        return  mDiagLogDao.loadAll();
    }

    public static List queryListByYearAndMonth(int year,int month){
        QueryBuilder<diagLog> qb = daoSession.queryBuilder(diagLog.class);

        List<diagLog> list1 = qb.where(qb.and(diagLogDao.Properties.Year.eq(year), diagLogDao.Properties.Month.eq(month))).list();
        return list1;
    }
}
